package com.wzdigit.wms.wms.service.core.trsn;

import com.wzdigit.wms.basic.client.response.asnHeader.ReceiveReportDtlExt;
import com.wzdigit.wms.basic.domain.order.TrsnDtl;
import com.wzdigit.wms.basic.enums.TrsnNoteTypeEnum;
import com.wzdigit.wms.basic.mapper.core.order.TrsnDtlMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 库存交易凭证明细表，记录系统生成的入库单、出库凭证明细 服务类
 * </p>
 *
 * @author
 * @since 2021-01-19
 */
@Service
@Slf4j
public class TrsnDtlService {

    @Autowired
    TrsnDtlMapper trsnDtlMapper;

    /**
     * 根据入参实体新增一条记录
     *
     * @param trsnDtl
     * @return
     */
    public TrsnDtl addNewOne(TrsnDtl trsnDtl) {
        int row = trsnDtlMapper.insert(trsnDtl);
        log.info("成功新增{}条记录", row);

        return trsnDtl;
    }

    /**
     * 根据入参实体更新一条记录
     *
     * @param trsnDtl
     * @return
     */
    public TrsnDtl updateOne(TrsnDtl trsnDtl) {
        int row = trsnDtlMapper.updateById(trsnDtl);
        log.info("成功更新{}条记录", row);

        return trsnDtl;
    }


    /**
     * 根据入参集合新增
     *
     * @param trsnDtlList
     * @return
     */
    public List<TrsnDtl> addNewList(List<TrsnDtl> trsnDtlList) {

        for (TrsnDtl trsnDtl : trsnDtlList) {
            addNewOne(trsnDtl);
        }
        return trsnDtlList;
    }
    
	/**
	 * 收货报表明细
	 * 
	 * @return
	 */
	public List<ReceiveReportDtlExt> selectAll(String fmDoc, String fmDocLine, Integer invUpdateFlag, String noteType) {
		// 入库凭证
		String inStorageCode = TrsnNoteTypeEnum.IN_STORAGE.getCode();
		// 过滤只需要入库凭证的
		return trsnDtlMapper.selectAll(fmDoc, fmDocLine, invUpdateFlag, noteType);
	}
}